package com.neo.scalaCookBook.C1_String

/**
  * Autuor : zhaoshun
  * Time   : 2017/10/17 6:44
  * Email  : tmby1314@163.com  
  */

/**
  * what are you to do something, describe it
  */


object StringsCreate {

  /**
    * 测试主函数
    * @param args
    */
  def main(args: Array[String]): Unit = {

    println("创建一个多行的字符串")
    val foo =
      """
This is

      a multiline
String
      """.stripMargin

    println(foo)

    println("解决对齐的问题")
    val foo1 =
      """This is
        |score and
        |seven years ago
      """.stripMargin
    println(foo1)
    println("如果不喜欢'|'符号，也可以自己定义")
    val foo2 =
      """Hello
        #world
        #!
      """.stripMargin('#')
    println(foo2)


    println("去掉换行符")
    val foo3 ="""Hello
        |world
        |!
      """.stripMargin.replaceAll("\n", " ")

    println(foo3)
    println("没成功")

    println("可以直接包含引号等，无需转义")
    val foo4 =
      """
        |"Hello"
        |'world'
      """.stripMargin
    println(foo4)


  }

}
